package com.cysd.ewmxns.sdw_ui.activity

import android.os.Bundle
import androidx.recyclerview.widget.GridLayoutManager
import com.cszy.ewmxns.base.BaseVMActivity
import com.cszy.ewmxns.ext.launch

import com.cysd.ewmxns.sdw_adapter.indexGridAdapter

import com.cysd.ewmxns.sdw_viewmodel.IndexViewModel
import com.hlyj.http.ad.NewGroMoreFeedAdManager
import com.hnyyac.ad.mds.IAdView
import com.hnyyac.ad.mds.IAdViewListener
import com.hnyyac.ad.mds.manager.AdManager
import com.hnyyac.ad.mds.manager.AdManager.AdLoadListener
import com.hnyyac.ad.mds.utils.BaseAdConstants
import qrrspeeelild.rqrc0ode.andro0ild.databinding.ActivitySelectChangjingBinding


class Sdw_SelectChangjingActivity : BaseVMActivity<IndexViewModel, ActivitySelectChangjingBinding>(),IAdViewListener {
    private var adapter: indexGridAdapter? = null
    private var newGromoreFeedAd : NewGroMoreFeedAdManager? =null
    override fun initView(savedInstanceState: Bundle?) {
        mBinding.headTitle.headCenterTitle.setText("选择场景")
    }


    override fun initData() {
        //获取首页grid数据
        adapter = indexGridAdapter()
        mBinding.recyChangjing.layoutManager= GridLayoutManager(this,2)
        mBinding.recyChangjing.adapter=adapter
        adapter?.submitList(mViewModel.getIndexGrid())
        AdManager.loadChapin_nocache(
            this,
            21,
            this,
            object : AdLoadListener {
                override fun onAdLoadFailed(ad: IAdView?) {
                    newGromoreFeedAd = NewGroMoreFeedAdManager(this@Sdw_SelectChangjingActivity, BaseAdConstants.FEEDAD_Id, mBinding?.fragmentContainer,62)
                    newGromoreFeedAd?.loadAd()
                }
            })

    }

    override fun initListener() {
       //返回
        mBinding.headTitle.headBack.setOnClickListener { v -> finish() }

        //非黑扫二维码
        mBinding.rvShibie.setOnClickListener {
            var bundle=Bundle()
            bundle.putString("type","general")
            launch(bundle,Sdw_QrcodeActivity::class.java)
        }
        //非黑生成二维码
        mBinding.rvSc.setOnClickListener {
            launch(Sdw_CreatQrCodeActivity::class.java)
        }
        //非黑扫码支付
        mBinding.rvPay.setOnClickListener {
            var bundle=Bundle()
            bundle.putString("type","general")
            launch(bundle,Sdw_QrcodeActivity::class.java)
        }
        adapter?.setOnItemClickListener{adapter, view, position ->
            var bundle=Bundle()
            bundle.putString("type","general")
            launch(bundle,Sdw_QrcodeActivity::class.java)
        }
    }

    override fun onTrigger(adView: IAdView) {

    }

    override fun onAdShow(adView: IAdView) {

    }

    override fun onAdClick(adView: IAdView) {

    }

    override fun onAdClose(adView: IAdView) {
        newGromoreFeedAd = NewGroMoreFeedAdManager(this@Sdw_SelectChangjingActivity, BaseAdConstants.FEEDAD_Id, mBinding?.fragmentContainer,62)
        newGromoreFeedAd?.loadAd()
    }

    override fun onError(msg: String) {

    }

    override fun onLoadError(adView: IAdView) {

    }

    override fun onSuccess(adView: IAdView) {

    }

    override fun onLoad(adView: IAdView) {

    }

    override fun onSkipped() {

    }

    override fun onNoAd() {

    }

    override fun onTimeOut() {

    }
}